<template>
    <div class="home-konwledges">
        <KnowLedge :knowledge="knowledge"></KnowLedge>
        <Pagination :pagination="pagination" @currentChange="currentChange"></Pagination>
    </div>
</template>
  
<script lang="ts" setup>
import { QueryKnowledgeAPI } from '../api/knowledge'

const knowledge = ref([]);

const pagination = ref({
    size: 10,
    total: 0,
    page: 1,
    searchValue: ''
});

onMounted(() => {
    queryKnowledge()
})

function queryKnowledge() {
    QueryKnowledgeAPI(pagination.value)
        .then((res) => {
            if (res.code === 200 && res.msg !== null) {
                knowledge.value = res.data.records
                pagination.value.total = res.data.total

            }
            if (res.code === 100 && res.msg !== null) {
                ElMessage.error(res.msg)
            }

        })
}

const currentChange = (val: number) => {
    pagination.value.page = val
    queryKnowledge()
}
</script>
  
<style></style>